/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
  <div>
    <div
      id="explanation"
      class="explanation"
      style="color: rgb(85, 85, 85); background-color: rgb(243, 244, 244); width: 98%; height: 100%;"
    >
      <div class="bckopa-tips">
        <div class="title">
          <img src="@/static/images/handd.png" alt />
          <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
        </div>
        <ul>
          <li>签到列表：签到人员记录，签到记录最多保持一个月</li>
          <li>签到规则：可设置功能开启关闭，签到积分和连续签到额外奖励</li>
        </ul>
      </div>
      <span title="收起提示" id="explanationZoom" style="display: block;"></span>
    </div>
    <form :model="form" class="form-horizontal" id="handleposition" method="post">
      <div class="ncap-form-default">
        <dl class="row">
          <dt class="tit">
            <label>签到送积分开关</label>
          </dt>
          <dd class="opt">
            <el-switch v-model="form.sign_on_off" :active-value="'1'" :inactive-value="'0'"></el-switch>
          </dd>
        </dl>
        <dl class="row">
          <dt class="tit">
            <label>签到送积分</label>
          </dt>
          <dd class="opt">
            <input
              v-model="form.sign_integral"
              onpaste="this.value=this.value.replace(/[^\d.]/g,'')"
              onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"
              class="input-txt"
            />
            <p class="notic">会员每次签到赠送的积分</p>
          </dd>
        </dl>
        <dl class="row">
          <dt class="tit">
            <label>连续签到（天）</label>
          </dt>
          <dd class="opt">
            <input
              v-model="form.sign_signcount"
              onpaste="this.value=this.value.replace(/[^\d.]/g,'')"
              onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"
              class="input-txt"
            />
            <p class="notic">会员连续签到可作为额外积分奖励</p>
          </dd>
        </dl>
        <dl class="row">
          <dt class="tit">
            <label>连续签到积分奖励</label>
          </dt>
          <dd class="opt">
            <input
              v-model="form.sign_award"
              onpaste="this.value=this.value.replace(/[^\d.]/g,'')"
              onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"
              class="input-txt"
            />
            <p class="notic">会员连续签到积分奖励，满足连续签将按此积分设置每天增加此积分，直到断签为止</p>
          </dd>
        </dl>
        <div class="bot">
          <el-button type="primary" @click="onSubmit()" :loading="isLoading">确认提交</el-button>
        </div>
      </div>
    </form>
  </div>
</template>

<script>
import { updateSignConfig } from "@/utils/api";
export default {
  data() {
    return {
      form: {},
      isLoading: false
    };
  },
  created() {
    this.getConfigs();
  },
  methods: {
    getConfigs() {
      var that = this;
      this.request
        .get("/mall/configs", { params: { inc_type: "sign" } })
        .then(function(res) {
          that.form = res.sign;
        });
    },
    onSubmit() {
      if (
        this.form.sign_integral < 1 ||
        this.form.sign_signcount < 1 ||
        this.form.sign_award < 1
      ) {
        this.$message.error("所有值只能输入大于1的整数");
        return;
      }
      this.isLoading = true;
      var that = this;
      updateSignConfig(that.form).then(function(res) {
        if (res.status == 1) {
          that.$message.success("保存成功");
        } else {
          that.$message.error(res.msg);
        }
        that.isLoading = false;
      });
    }
  }
};
</script>

<style scoped>
</style>
